<script setup>

</script>

<template>
  <div class="person">
    <h2>年龄：{{ age }}</h2>
    <h2>车辆信息：一台{{ car.brand }}，价格{{car.price}}</h2>
    <button @click="changeAge">修改年龄</button>
    <button @click="changeCar">修改车辆</button>
    <button @click="changeCarPrice">修改价格</button>
  </div>
</template>

<script setup>
    import {ref, reactive} from 'vue'
    let age = ref(19);
    let car = reactive({brand: '奔驰', price: 200});

    function changeAge() {
      age.value ++;
      console.log(age);
    }
    function changeCarPrice() {
      car.price += 100;
      console.log(car);
    }
    function changeCar() {
      Object.assign(car, {brand: '奥拓', price: 100});
      console.log(car);
    }
</script>

<style scoped>
  .person {
    background-color: skyblue;
    box-shadow: 0 0 10px;
    border-radius: 10px;
    padding: 20px;
  }

  button {
    margin: 0 5px;
  }
</style>